package
{
	import com.ming.ui.controls.Button;
	import com.ming.ui.controls.core.UIComponent;
	
	import flash.filters.GlowFilter;
	import flash.text.TextField;

	public class ClassFactory
	{
		private static var _instance:ClassFactory;
		private var btnNum:int = 0;
		private var uiNum:int = 0;
		public static function getInstance():ClassFactory
		{
			if (_instance==null)
				_instance = new ClassFactory();
			return _instance;
		}
		public function ClassFactory()
		{
		}
		
		public function getObjectByName(className:String,name:String=""):*
		{
			if (className=="Button")
			{
				var btn:Button = new Button();
//				if (name=="")
//				{
//					btnNum++;
//					btn.name = "btn"+btnNum;
//				}
//				else
//					btn.name = name;
				btn.width = 75;
				btn.height = 25;
				btn.label = "按钮";
				return btn;
			}
			else if (className=="UIComponent1")
			{
				var ui:UIComponent = new UIComponent();
//				if (name=="")
//				{
//					uiNum++;
//					ui.name = "ui"+uiNum;
//				}
//				else
//					ui.name = name;
				Style.setRightSpriteStyle(ui);
				ui.width = 200;
				ui.height = 200;
				return ui;
			}
			else if (className=="UIComponent2")
			{
				ui = new UIComponent();
//				if (name=="")
//				{
//					uiNum++;
//					ui.name = "ui"+uiNum;
//				}
//				else
//					ui.name = name;
				Style.setInnerSpriteStyle(ui);
				ui.width = 200;
				ui.height = 200;
				return ui;
			}
			else if (className=="TextField")
			{
				var textField:TextField = new TextField();
				textField.width = 80;
				textField.height = 20;
				textField.defaultTextFormat = Style.textFormat;
				textField.htmlText = "TextField";
				textField.selectable = false;
				textField.filters=[new GlowFilter(0x000000,1,3,3,4)];
				textField.wordWrap = true;
				textField.multiline = true;
				return textField;
			}
		}
	}
}